<template>
  <div>
    <el-row
      :span="24"
      class="body"
      style="margin-left: 0; margin-right: 0; "
      :gutter="20"
    >
      <el-col
        :span="12"
        class="content"
        style="position: relative; padding: 0 !important"
      >
        <div id="charts1"   class="line"
             :style="{ width: '100%', margin: '0 auto' }"
             ref="charts1"></div>
      </el-col>
      <el-col
        :span="12"
        class="content"
        style="position: relative; padding: 0 !important"
      >
        <div id="charts2"   class="line"
             :style="{ width: '100%', margin: '0 auto' }"
             ref="charts2"></div>
      </el-col>
      <el-col
        :span="24"
        class="content"
        style="position: relative; padding: 0 !important"
      >
        <div id="charts3"   class="line"
             :style="{ width: '100%', margin: '0 auto' }"
             ref="charts3"></div>
      </el-col>
    </el-row>
    </div>
</template>

<script>
import * as echarts from "echarts";
export default{
 mounted() {
   this.drawChart1();
   this.drawChart2();
 },
  methods:{
    //图表1
    drawChart1() {
      var chartDom = document.getElementById('charts1');
      var myChart = echarts.init(chartDom);
      var option;
      option = {
        title: {
          text: '护理服务统计',
           //subtext: 'Fake Data',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: '护理项目',
            type: 'pie',
            radius: '50%',
            data: [
              { value: 3, name: '送餐助餐' },
              { value: 4, name: '生活照料' },
              { value: 8, name: '康复护理' },
              { value: 1, name: '应急服务' },
              { value: 0, name: '精神慰藉' },
              { value: 3, name: '其他' }
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };
      option && myChart.setOption(option);
    },

    drawChart2() {
      var chartDom = document.getElementById('charts2');
      var myChart = echarts.init(chartDom);
      var option;
      option = {
        title: {
          text: '护理完成情况统计',
          // subtext: 'Fake Data',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          top: '5%',
          left: 'center'
        },
        series: [
          {
            name: '完成情况',
            type: 'pie',
            radius: ['40%', '70%'],
            avoidLabelOverlap: false,
            label: {
              show: false,
              position: 'center'
            },
            emphasis: {
              label: {
                show: true,
                fontSize: 40,
                fontWeight: 'bold'
              }
            },
            labelLine: {
              show: false
            },
            data: [
              { value: 6, name: '已服务' },
              { value: 5, name: '未服务' },
              { value: 1, name: '已取消' }
            ]
          }
        ]
      };
      option && myChart.setOption(option);
    },
  }
}
</script>

<style scoped>
.line{
  height: 1000px;
  padding: 10px;
}
</style>
